<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>课表分配</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
    <script src="../../layui/layui.js" charset="utf-8"></script>
    <script src="../../jquery/jquery.min.js" charset="utf-8"></script>
    <script>

        layui.use(['form', 'layedit', 'laydate'], function(){
            var form = layui.form
                    ,layer = layui.layer
                    ,layedit = layui.layedit
                    ,laydate = layui.laydate,
                    $ = layui.$;
            //日期
            laydate.render({
                elem: '#date'
            });
            laydate.render({
                elem: '#date1',
            });
            laydate.render({
                elem: '#date2',
                type: 'year',
                range: true
            });
            form.verify({

            });

            //监听提交
            form.on('submit(demo)', function (data) {
                var datas=data.field; //以json格式接收表单中所有的数据
                var action=data.form.action;

                $.ajax({
                    url:action,
                    data:datas,
                    type:"POST",
                    dataType:"json",
                    success:function(flag){

                        if (flag==1) {
                            layer.msg('课程分配成功，您可以继续添加或点击返回！',{icon: 1,time:3000}, function(){
                                window.location.reload();
                            });

                        } else if(flag==-1){
                            layer.msg('该时间已被其他课程占用！');
                        }else{
                            layer.msg('出错啦！');
                        }
                    },
                    error:function(error){
                        console.log(error);
                    }
                });
                return false;

            });

        });
    </script>
</head>
<body>
<form class="layui-form layui-form-pane"  action="/courseTable/saveCourseTable" style="margin:auto; width:82%;" method="post" >
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
        <legend style="text-align:center;" ><h2>课表分配</h2></legend>
    </fieldset>
    <div class="layui-form-item" style="text-align: center">
        <div class="layui-inline" style="margin-bottom: 30px;">
            <label class="layui-form-label" >课程名称：</label>
            <div class="layui-input-inline">

                <select id="courseName"  name="courseName" value="">
                    <option value="">请选择</option>
                   <#list courseList as cl>
                            <option value="${cl.cName}">${cl.cName}</option>
                   </#list>
                </select>
            </div>
        </div>
        <br>
        <div class="layui-inline" style="margin-bottom: 30px;">
            <label class="layui-form-label" >周次：</label>
            <div class="layui-input-inline">

                <select id="weekNum"  name="weekNum" value="">
                    <option value="">开始周次</option>
                   <#list weekNameList as dictionary>
                            <option value="${dictionary.dictionaryKey}">${dictionary.dictionaryName}</option>
                   </#list>
                </select>

            </div>
            <div class="layui-input-inline">
            <select id="weekNum"  name="weekNum1" value="">
                <option value="">结束周次</option>
                   <#list weekNameList as dictionary>
                            <option value="${dictionary.dictionaryKey}">${dictionary.dictionaryName}</option>
                   </#list>
            </select>
            </div>
        </div>
        <br>
        <div class="layui-inline" style="margin-bottom: 30px;">
            <label class="layui-form-label" >上课时间：</label>
            <div class="layui-input-inline">

                <select id="weekend"  name="weekend" value="">
                    <option value="">请选择</option>
                   <#list weekendNameList as dictionary>
                            <option value="${dictionary.dictionaryKey}">${dictionary.dictionaryName}</option>
                   </#list>
                </select>
            </div>
        </div>
        <div class="layui-inline" style="margin-bottom: 30px;">
            <label class="layui-form-label" >具体时间：</label>
            <div class="layui-input-inline">

                <select id="time"  name="time" value="">
                    <option value="">请选择</option>
                            <option value="12">1-2节</option>
                            <option value="34">3-4节</option>
                            <option value="56">5-6节</option>
                            <option value="78">7-8节</option>
                            <option value="910">9-10节</option>
                            <option value="1112">11-12节</option>

                </select>
            </div>
        </div>


    </div>
    <div class="layui-form-item" style="text-align:center">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal layui-btn-lg" lay-submit=""  lay-filter="demo">提交</button>&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="/courseTable/tocourseTable" class="layui-btn layui-btn-lg">返回</a>
        </div>
    </div>
    </div>
</form>

<div style="height:250px"></div>

</body>
</html>
